#pragma once
#include <cmath>

#define PI 3.14159265359f
#define EPSILON 0.00001f

namespace MathUtil
{
    /*
    * 
    * 返回最小弧长，欧拉角封装 将角度限制线[-180°,+180°] 之间 
    * warpPi(x) =  x - 360 [(x+ 180) /360]   
    */
    float warpPi(float theta)
    {
        if(fabs(theta) >=PI)
        {
            const float  TWOPI = 2.0f * PI;
            //floor 向下取整
            float revolutions = floor((theta + PI) * (1.0f / TWOPI));

            theta -= revolutions * TWOPI;
        }

        return theta;
    }

}